﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ExtendPropertyLib.WPF;
using ExORMDesginer.Plugin;

namespace ExORMDesginer.UserControls.Dialogs
{
    /// <summary>
    /// Interaction logic for EntityInfomationDialogView.xaml
    /// </summary>

    public partial class EntityInfomationDialogView : UserControl
    {
        public EntityInfomationDialogView()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            editer.EditerType = CCodeEditer.EditerType.SQL;
            editer.Init();
            label1.MouseDown += new MouseButtonEventHandler(label1_MouseDoubleClick);
            var vm = this.DataContext as EntityInfomationDialogViewModel;
            if (vm.Model.EntityInfo.EntityViewType == EntityType.StoredProcedure || vm.Model.EntityInfo.EntityViewType == EntityType.View)
            {
                grid.RowDefinitions[1].Height = new GridLength(250.0, GridUnitType.Star);
                grid.RowDefinitions[2].Height = new GridLength(250.0,GridUnitType.Star);
                editer.Height = 250;
            }


        }

        void label1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            tb1.Visibility = Visibility.Visible;
            label1.Visibility = Visibility.Collapsed;
            tb1.LostFocus += (s, ev) =>
            {
                tb1.Visibility = Visibility.Collapsed;
                label1.Visibility = Visibility.Visible;

            };

          

        }
    }
}
